﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Ad_makeCode : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            string adid = Request.QueryString["adid"];
            if (adid != null)
            {
                ShowAd(adid);
            }
        }
    }
    public void ShowAd(string adid)
    {
        BLL.Ad adbll = new BLL.Ad();
        Model.Ad admodel = adbll.GetModel(adid);
        lbadid.Text = admodel.Adid;
        lbADName.Text = admodel.AdName;

        if (admodel.AdAttribute1.Trim() == "pic")
        {

        }
        if (admodel.AdAttribute1.Trim() == "char")
        {
            

        }
        if (admodel.AdAttribute1.Trim() == "picchar")
        {

            txtAdAttribute4.Text = admodel.AdAttribute4;
        }       
    }


    protected void btnCode_Click(object sender, EventArgs e)
    {

        BLL.Ad adbll = new BLL.Ad();
        Model.Ad admodel = adbll.GetModel(lbadid.Text );
        lbadid.Text = admodel.Adid;
        lbADName.Text = admodel.AdName;
        string str = "<div style=\"background-image:url(" + ConfigurationManager.AppSettings["DomainName"].ToString() + "/logo123.gif?showpage=" + lbadid.Text.Trim() + "); width:" + txtwidth.Text + "px;   height:" + txtheight.Text + "px; background-repeat:repeat-y; \">";


        if (admodel.AdAttribute1.Trim() == "pic")
        {
            //AdPicAddress   广告图片地址
            //AdPicUrl  或图片网址  ConfigurationManager.AppSettings["women"].ToString()

            if (admodel.AdPicAddress != "")
            {
                str = str + "<a href =\" " + ConfigurationManager.AppSettings["DomainName"].ToString() + "/Poster.aspx?adixd=" + admodel.Adid.ToString() + "&&urxl=" + admodel.AdLink.ToString() + "\"><IMG SRC=" + admodel.AdPicAddress + " WIDTH=90 HEIGHT=92 BORDER=0></a>";
            }

            if (admodel.AdPicUrl != "")
            {

                str = str + "<a href =\"" + ConfigurationManager.AppSettings["DomainName"].ToString() + "/Poster.aspx?adixd=" + admodel.Adid.ToString() + "&&urxl=" + admodel.AdLink.ToString() + "\"><IMG SRC=" + admodel.AdPicUrl + " WIDTH=90 HEIGHT=92 BORDER=0> </a>";
            }
        }

        if (admodel.AdAttribute1.Trim() == "char")
        {
            str = str + "<a href =\" " + ConfigurationManager.AppSettings["DomainName"].ToString() + "/Poster.aspx?adixd=" + admodel.Adid.ToString() + "&&urxl=" + admodel.AdLink.ToString() + "\">" + admodel.AdAttribute3 + "</a>";
        }



        if (admodel.AdAttribute1.Trim() == "picchar")
        {
            str = str + admodel.AdAttribute4;
        }
        str = str +  "</div>";
        txtAdAttribute4.Text = str;

    }
}
